<?php


namespace app\pushnotify\controller;


use think\Controller;
use think\Log;

/**
 * 极光推送回执信息类 // huawei=>5 xiaomi=>4 vivo=>3 oppo=>2 极光=> 1
 * Class Oppo
 * @package app\pushnotify\controller
 */
class Oppo extends Controller
{
    public function index()
    {
        if ($this->request->isPost())
        {
            $data = $this->request->param();
//            Log::write('oppo推送回调回执信息' . json_encode($data, true), 'log', true);
            foreach ($data as $item)
            {
                if (isset($item['param']) && $item['param'])
                {
                    [$thingType, $pushId] = explode('_', $item['param']);

                    $d = [
                        'thing_type' => $thingType,
                        'push_id' => $pushId,
                        'appId' => $item['appId'],
                        'messageId' => $item['messageId'],
                        'eventType' => $item['eventType'],
                        'regids' => "'" . $item['registrationIds'] . "'",
                    ];
                    // 记录日志
                    Log::write($d, '2_flog_push_return', true);
                }
            }
        }
    }
}
